$(function(){
	shanPing();
	$.loadmore.get(getData, {scroll: true});
})

window.onload = function(){
	shanPing();
	window.onscroll();
}


/* 加载更多 */
function getData(config){
	config.isAjax = true;
	$.ajax({
		type : "GET", 
		dataType : "json",
		url : "../../json/blog.json",
		data : {},
		success: function(reponse){
			config.isAjax = false;
			//to do something....
			$(".shop_list_content").append('<p>2121</p>');
			$(".clickmore").html('加载更多');
			/******************隐藏more*************************/
			/*if ( (offset + size) >= sum){
				$(".clickmore").hide();
				//停止滚动加载请求
				config.isEnd = true; 
			}else{
				$(".clickmore").show();
			}*/
		},
		error: function(xhr, type){
			console.log('Ajax error!');
		}
	});
}
/* 闪屏 */
function shanPing(){
	if(getCookie('loadState')){
		$('#shanping').hide();
		$('html').css('overflow-y','scroll');
		$('body').css('overflow-y','scroll');
	}else{
		$('#shanping').show();
		$('html').css('overflow-y','hidden');
		$('body').css('overflow-y','hidden');
		setCookie('loadState','true');
	}
}
/* COOKIE */
function setCookie(name,value)
{
    var Days = 1;
    var exp = new Date();
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = name + "="+ escape(value) + ";path=/;expires=" + exp.toGMTString();
}
function getCookie(name){
	var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
	if(arr=document.cookie.match(reg))
	return unescape(arr[2]);
	else
	return null;
}
